import unittest
from time import sleep

from selenium import webdriver


from page.page_login import PageLogin
from parameterized import parameterized

from util import read_json


class TestLogin(unittest.TestCase):
    def setUp(self) -> None:
        self.driver=webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.get('http://192.168.79.150/Home/user/login.html')
        self.login=PageLogin(self.driver)

    def tearDown(self) -> None:
        sleep(3)
        self.driver.quit()
    @parameterized.expand(read_json("login.json",'login'))
    def test01_login(self,desc,phone,password,code,expect):
        try:
            self.login.page_login(phone,password,code)
            #断言
            nickname=self.login.page_get_nickname()
            self.assertEqual(nickname,expect )
        except Exception as e:
            print("错误",e)
